package com.piggy.core.executor.impl;

import com.alibaba.fastjson2.JSONObject;
import com.piggy.core.executor.Executor;
import com.piggy.core.client.DubboClient;
import com.piggy.core.model.HttpStatement;
import io.netty.channel.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DubboExecutor implements Executor {

    private final static Logger Logger = LoggerFactory.getLogger(DubboExecutor.class);

    private final HttpStatement httpStatement;

    private final JSONObject jsonObject;

    public DubboExecutor(HttpStatement httpStatement, JSONObject jsonObject){
        this.httpStatement = httpStatement;
        this.jsonObject = jsonObject;
    }

    public HttpStatement getHttpStatement() {
        return httpStatement;
    }

    public JSONObject getJsonObject() {
        return jsonObject;
    }

    @Override
    public void execute(Channel channel) {
        DubboClient.send(httpStatement, jsonObject, channel);
    }
}
